home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 2002 #11 / Amiga Plus CD - 2002 - No. 11.iso / Tools / Development / ncurses-5.3 / ncurses / tinfo / MKfallback.sh < prev    next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  2002-10-27  |  1.6 KB  |  103 lines

  1. #!/bin/sh
  2. # $Id: MKfallback.sh,v 1.11 2001/12/02 01:55:30 tom Exp $
  3. #
  4. # MKfallback.sh -- create fallback table for entry reads
  5. #
  6. # This script generates source code for a custom version of read_entry.c
  7. # that (instead of reading capabilities for an argument terminal type
  8. # from an on-disk terminfo tree) tries to match the type with one of a
  9. # specified list of types generated in.
  10. #
  11.  
  12. terminfo_dir=$1
  13. shift
  14.  
  15. terminfo_src=$1
  16. shift
  17.  
  18. if test $# != 0 ; then
  19.     tmp_info=tmp_info
  20.     echo creating temporary terminfo directory... >&2
  21.  
  22.     TERMINFO=`pwd`/$tmp_info
  23.     export TERMINFO
  24.  
  25.     TERMINFO_DIRS=$TERMINFO:$terminfo_dir
  26.     export TERMINFO_DIRS
  27.  
  28.     tic $terminfo_src >&2
  29. else
  30.     tmp_info=
  31. fi
  32.  
  33. cat <<EOF
  34. /*
  35.  * DO NOT EDIT THIS FILE BY HAND!  It is generated by MKfallback.sh.
  36.  */
  37.  
  38. #include <curses.priv.h>
  39. #include <term.h>
  40.  
  41. EOF
  42.  
  43. if [ "$*" ]
  44. then
  45.     cat <<EOF
  46. #include <tic.h>
  47.  
  48. /* fallback entries for: $* */
  49. EOF
  50.     for x in $*
  51.     do
  52.         echo "/* $x */"
  53.         infocmp -E $x
  54.     done
  55.  
  56.     cat <<EOF
  57. static const TERMTYPE fallbacks[$#] =
  58. {
  59. EOF
  60.     comma=""
  61.     for x in $*
  62.     do
  63.         echo "$comma /* $x */"
  64.         infocmp -e $x
  65.         comma=","
  66.     done
  67.  
  68.     cat <<EOF
  69. };
  70.  
  71. EOF
  72. fi
  73.  
  74. cat <<EOF
  75. NCURSES_EXPORT(const TERMTYPE *) _nc_fallback (const char *name GCC_UNUSED)
  76. {
  77. EOF
  78.  
  79. if [ "$*" ]
  80. then
  81.     cat <<EOF
  82.     const TERMTYPE    *tp;
  83.  
  84.     for (tp = fallbacks;
  85.          tp < fallbacks + sizeof(fallbacks)/sizeof(TERMTYPE);
  86.          tp++)
  87.     if (_nc_name_match(tp->term_names, name, "|"))
  88.         return(tp);
  89. EOF
  90. else
  91.     echo "    /* the fallback list is empty */";
  92. fi
  93.  
  94. cat <<EOF
  95.     return((TERMTYPE *)0);
  96. }
  97. EOF
  98.  
  99. if test -n "$tmp_info" ; then
  100.     echo removing temporary terminfo directory... >&2
  101.     rm -rf $tmp_info
  102. fi
  103.